import {
  reqMyShopCart,
  reqMyRecommend,
  reqDelete,
  reqChange,
  // reqAllChange,
  // reqAllDelete,
} from "@/api";
export default {
  state: {
    shopcartList: [],
    recommend: [],
  },
  mutations: {
    UPDATE_SHOPCARTLIST(state, shopcartList) {
      state.shopcartList = shopcartList;
    },
    MYRECOMMEND(state, recommend) {
      state.recommend = recommend;
    },
  },
  actions: {
    // 获取购物车列表
    async getShopcartList({ commit }) {
      const res = await reqMyShopCart();

      // console.log(res, "55");
      commit("UPDATE_SHOPCARTLIST", res);
    },

    // 获取推荐物
    async getMyRecommend({ commit }) {
      const res = await reqMyRecommend();
      commit("MYRECOMMEND", res);
    },

    // 删除单个商品
    async getDelete({ commit }, id) {
      reqDelete(id);
    },

    // 修改单个状态
    async getChange({ commit }, data) {
      reqChange(data);
    },
  },
  getters: {},
};
